package com.neusoft.config;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    private static final long serialVersionUID = 1L;

    private int status;

    private String message;

    private Object data;

    final static Result SUCCESS = Result.success();

    private Result() {
    }

    public static Result success() {
        Result result = new Result();
        result.setStatus(1);
        return result;
    }

    public static Result error(String message) {
        Result result = new Result();
        result.setStatus(0);
        result.setMessage(message);
        return result;
    }

    public static Result success(String message) {
        Result result = new Result();
        result.setStatus(1);
        result.setMessage(message);
        return result;
    }

    public static Result SUCCESS(Object o) {
        Result result = new Result();
        result.setStatus(1);
        result.setData(o);
        return result;
    }

    @Override
    public String toString() {
        return "Result{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
